﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TheLoaiSach.aspx.cs" Inherits="TheLoaiSach" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MessageContaint" Runat="Server">
Quản lý Thể Loại Sách
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContain" Runat="Server">
<br/>
<h4>Thêm thể loại sách</h4>

    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="MaTheLoaiSach" DataSourceID="SqlDataSourceThemTheLoaiSach" 
        DefaultMode="Insert" Height="50px" Width="125px">
        <Fields>
            <asp:BoundField DataField="MaTheLoaiSach" HeaderText="MaTheLoaiSach" 
                InsertVisible="False" ReadOnly="True" SortExpression="MaTheLoaiSach" />
            <asp:BoundField DataField="TenTheLoaiSach" HeaderText="TenTheLoaiSach" 
                SortExpression="TenTheLoaiSach" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSourceThemTheLoaiSach" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PublisherDBConnectionString %>" 
        DeleteCommand="DELETE FROM [TheLoaiSach] WHERE [MaTheLoaiSach] = @MaTheLoaiSach" 
        InsertCommand="INSERT INTO [TheLoaiSach] ([TenTheLoaiSach]) VALUES (@TenTheLoaiSach)" 
        SelectCommand="SELECT * FROM [TheLoaiSach]" 
        UpdateCommand="UPDATE [TheLoaiSach] SET [TenTheLoaiSach] = @TenTheLoaiSach WHERE [MaTheLoaiSach] = @MaTheLoaiSach">
        <DeleteParameters>
            <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenTheLoaiSach" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenTheLoaiSach" Type="String" />
            <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

<br/>
<h4>Danh sách thể loại sách</h4>
<hr/>
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataKeyNames="MaTheLoaiSach" 
        DataSourceID="SqlDataSourceTheLoaiSach">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="MaTheLoaiSach" HeaderText="MaTheLoaiSach" 
                InsertVisible="False" ReadOnly="True" SortExpression="MaTheLoaiSach" />
            <asp:BoundField DataField="TenTheLoaiSach" HeaderText="TenTheLoaiSach" 
                SortExpression="TenTheLoaiSach" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSourceTheLoaiSach" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PublisherDBConnectionString %>" 
        DeleteCommand="DELETE FROM [TheLoaiSach] WHERE [MaTheLoaiSach] = @MaTheLoaiSach" 
        InsertCommand="INSERT INTO [TheLoaiSach] ([TenTheLoaiSach]) VALUES (@TenTheLoaiSach)" 
        SelectCommand="SELECT * FROM [TheLoaiSach]" 
        UpdateCommand="UPDATE [TheLoaiSach] SET [TenTheLoaiSach] = @TenTheLoaiSach WHERE [MaTheLoaiSach] = @MaTheLoaiSach">
        <DeleteParameters>
            <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenTheLoaiSach" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenTheLoaiSach" Type="String" />
            <asp:Parameter Name="MaTheLoaiSach" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

</asp:Content>

